from datas.common import CommonData
from pages.BasePage import BasePage
from locator.home_locator.HomeLocators import HomeLocator
from datas.LoginDatas import LoginData as LD
from pages.home.LoginPages import LoginPage
from pages.initDriver import Drivers


class IsLogin(BasePage):

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = Drivers().get_driver()
        self.driver.maximize_window()
        self.driver = driver
        self.LP = LoginPage(self.driver)

    # 用户头像是否存在
    def is_login(self):
        path = "判断是否登录"
        return self.wait_element_presence(locator=HomeLocator.userImage, path=path)

    def login(self):
        """test_login_success：正常登录成功"""
        self.driver.get(CommonData.BaseUrl)
        self.LP.user_login(LD.right_login[0]["user"], LD.right_login[0]["passwd"])
